package com.bsf.wcp;

import lombok.val;
import org.omg.SendingContext.RunTime;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

import javax.annotation.Resource;
import javax.naming.Context;

/**
 * @author: chejiangyi
 * @create: 2019-05-14 16:55
 **/
@SpringBootApplication
public class Application {
    private static boolean exit=false;
    public static void main(String[] args) {
        val context = SpringApplication.run(Application.class, args);

        Runtime.getRuntime().addShutdownHook(new Thread(()->{
            exit=true;
        }));

        val wcp = context.getBean(Wcp.class);

        while (exit==false)
        {
            try {
                wcp.run();
            }
            catch (Exception exp)
            {}
            try{Thread.sleep(wcp.getSpiderSleep());}catch (Exception exp){}
        }
    }
}
